home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 209
/
209.d81
/
base converter
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
827b
|
23 lines
10 poke53280,.:poke53281,.
100 print"[147] [154]universal base converter - art skiles":er$="^^?"
110 n$="":input "numeral to convert";n$:if n$="" then end
120 input" from base (2-36)";f:if f<2 or f>36 then print tab(20);er$:goto 120
130 input" to base (2-36)";t:if t<2 or t>36 then print tab(20);er$:goto 130
140 x=0:for z=1 to len(n$):a=asc(mid$(n$,z,1))
150 b=a+48*(a>47 and a<58)+55*(a>64 and a<91)+85*(a>96 and a<123)
160 if b>=f then print "error in numeral to convert!":goto 110
170 x=x*f+b:next z:cn$=""
180 b=x-int(x/t)*t:x=(x-b)/t
190 a=b-48*(b<10)-55*(b>9)
200 cn$=chr$(a)+cn$:if x then 180
210 print " converted numeral: ";cn$
220 print"press space to convert another or"
230 print"q to quit."
240 a=peek(203):ifa<>60anda<>62then240
250 ifa=60thenrun
255 d=peek(186):ifd<8thend=8
260 print"[147][144]load"chr$(34)"b.tips and trick"chr$(34)","d
270 print"run"
280 poke631,13:poke632,13:poke198,2:end
10000 d=peek(186):n$="base converter":open15,d,15,"s0:"+n$:close15:saven$,d:end